/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Conn.mysqlconnect;
import ModelKelas.Pendaftaran;

import java.sql.Connection;
import java.sql.ResultSet;

import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author AnggitDwiantoro
 */
public class PasienControl {

    private Connection conn;

    public PasienControl(Connection koneksi) {
        this.conn = koneksi;
    }

    public static PasienControl getKoneksi() throws SQLException {
        PasienControl kon = new PasienControl(mysqlconnect.ConnectDb());
        return kon;
    }

    public void cariPasien(String pas) throws SQLException {
        Statement statement = null;
        ResultSet result = null;

        try {
            statement =(Statement) conn.createStatement();
            String sql = "SELECT noIndex, Alamat, namaPasien FROM pasien"
                    + " WHERE namaPasien='" + pas + "'";
            result = (ResultSet) statement.executeQuery(sql);
            while (result.next()) {
                Pendaftaran pendaf = new Pendaftaran();
                pendaf.setNamaPasien(result.getString("namaPasien"));
                pendaf.setAlamatPasien(result.getString("Alamat"));
                pendaf.setNo_Index(result.getString("noIndex"));
            }
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(PasienControl.class.getName()).log(Level.SEVERE, null, ex);

        }
    }
}
